﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace STX.Admin.Models
{
    public class PagerModel
    {
        public int Total { get; set; }
        public int Page { get; set; }
        public int PageSize { get; set; }
        public int PageCount
        {
            get
            {
                if (PageSize == 0 || Total == 0) return 0;
                return (int)Math.Ceiling((double)Total / PageSize);
            }
        }

        private int num = 5;
        public int Start
        {
            get
            {
                int s = Page - num;
                int e = Page + num;
                if (e > PageCount)
                {
                    s -= PageCount - e;
                }
                if (s < 1)
                {
                    s = 1;
                }
                return s;
            }
        }
        public int End
        {
            get
            {
                int e = Page + num;
                int s = Page - num;
                if (s < 1)
                {
                    e += 1 - s;
                }
                if (e > PageCount)
                {
                    e = PageCount;
                }
                return e;
            }
        }
    }
}